/**
 * Copyright 2009 Henning Teek, Ingo Renner
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.chigs.web;

import java.io.InputStream;

import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import brix.Plugin;
import brix.config.BrixConfig;

import com.googlecode.chigs.web.plugin.ChigsPlugin;
import com.googlecode.chigscommons.web.WicketApplication;
import com.googlecode.chigscommons.web.WicketBrix;

/**
 * @author Ingo Renner
 * @author Henning Teek
 */
public class ChigsApplication extends WicketApplication {
	private final static Logger log = LoggerFactory.getLogger(ChigsApplication.class);

	@Override
	protected void init() {
		super.init();
		log.info("chigs application initialized");
	}

	@Override
	protected WicketBrix getWicketBrix(BrixConfig config) {
		final WicketBrix wicketBrix = super.getWicketBrix(config);
		config.getRegistry().register(Plugin.POINT, new ChigsPlugin(wicketBrix));
		return wicketBrix;
	}
	
	@Override
	protected InputStream getWorkspaceXml() {
		return getClass().getResourceAsStream("workspace.xml");
	}

	@Override
	public Session newSession(Request request, Response response) {
		return new ChigsWebSession(request);
	}

	@Override
	protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
		return ChigsWebSession.class;
	}
}
